<template>
  <div class="rights-wrap">
    <slot name="title">
      <div class="title">
        <img :src="packages.icon" />
        {{packages.name}}
      </div>
    </slot>
    <el-row :gutter="5" type="flex" class="rights-row" v-for="(cList,i) in list" :key="i">
      <el-col :span="8" v-for="(it,i) in cList" :key="i">
        <div class="rights-item">
          <img :src="it.p_icon" :alt="it.name">{{it.name.replace('\n', '')}}
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'RightsListV2',
  props: {
    packages: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  computed: {
    list () {
      let data = this.packages.cat_list || []
      data = data.reduce((arr, it) => {
        return arr.concat(it.right_list)
      }, [])

      return new Array(Math.ceil(data.length / 3)).fill(0).map((v, i) => {
        const si = i * 3
        const ei = (i + 1) * 3
        return data.slice(si, ei)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.rights{
  &-wrap{
    padding:  18px 34px 25px;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    .title{
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: bold;
      color: #F8DE9D;
      font-size: 15px;
      margin-bottom: 18px;
      img{
        width: 20px;
        height: 20px;
        margin-right: 8px;
      }
    }
  }
  &-row{
    & + &{
      margin-top: 12px;
    }
  }
  &-item{
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 400;
    text-align: left;
    img{
      flex: 0 0 22px;
      width: 22px;
      height: 22px;
      margin-right: 10px;
      border-radius: 4px;
      background: linear-gradient(180deg, #FFF2D2 0%, #F8DD99 100%);
    }
  }
}
</style>
